import org.joda.time.*

class EventPt
{
    def title = "title"
    def description = "description"
    
    def DateTime startDate
    def DateTime endDate

    def boolean isDuration = false
    def boolean isExact = true

    def link = ""
    def imageLink = ""

    def String toString()
    {
        def startDateStr = Utils.getFormattedDateTime(startDate)
        def endDateStr = ""
        if(endDate!=null)
            endDateStr = Utils.getFormattedDateTime(endDate)
        def isDurationStr = isDuration == true?"true":"false"
        def isExactStr = isExact == true?"true":"false"
        def title = title
        def description = title + "<b>Start</b>:" + Utils.getFormattedDateTime(startDate) + " <b>End:</b>"+Utils.getFormattedDateTime(endDate)

        def eventPtStr = "Start Date:${startDateStr}, IsDuration: ${isDurationStr}, End Date:${endDateStr}"

        return eventPtStr
    }

    def String getXml()
    {
        def startDateStr = Utils.getFormattedDateTime(startDate)
        def endDateStr = Utils.getFormattedDateTime(endDate)
        def isDurationStr = isDuration == true?"true":"false"
        def isExactStr = isExact == true?"true":"false"
        def title = title
        def description = title + "<b>Start</b>:" + Utils.getFormattedDateTime(startDate) + " <b>End:</b>"+Utils.getFormattedDateTime(endDate)

        def eventPtStr = """
        <event
            start = "${startDateStr}"
            end = "${endDateStr}"
            isDuration = "${isDurationStr}"
            isExact = "${isExactStr}"
            title = "${title}"
            link = "${link}"
            imageLink = "${imageLink}">
            $description
        </event>
        """

        return eventPtStr
    }

    def String getJson()
    {
        def startDateStr = Utils.getFormattedDateTime(startDate)
        def endDateStr = Utils.getFormattedDateTime(endDate)
        def isDurationStr = isDuration == true?"true":"false"
        def isExactStr = isExact == true?"true":"false"
        def title = title
        def description = title + "<b>Start</b>:" + Utils.getFormattedDateTime(startDate) + " <b>End:</b>"+Utils.getFormattedDateTime(endDate)
        def eventPtStr = ""

        if(isDuration)
        {
            eventPtStr = """
                {
                'start':"${startDateStr}",
                'end':"${endDateStr}",
                'durationEvent':${isDuration},
                'title':"${title}",
                'link':"${link}",
                'imageLink':"${imageLink}",
                'description':"${description}"
                }
            """
        }
        else
        {
            eventPtStr = """
                {
                'start':"${startDateStr}",
                'durationEvent':${isDuration},
                'title':"${title}",
                'link':"${link}",
                'imageLink':"${imageLink}",
                'description':"${description}"
                }
            """
        }

        return eventPtStr
    }
}
